package com.training.java.core.collections.post15;

import java.util.Set;
import java.util.TreeSet;

/**
 * this demo is to observe collections TreeSet. Should not take
 * nulls,duplicates. Should give the list in alphabetical order. Observe that
 * TreeSet keeps these elements in a natural order.
 * 
 * @author soumya
 * 
 */
public class StudentTreeSetDemo {

	public static void main(String[] args) {

		Set<String> names = new TreeSet<String>();

		// Adding String Objects to set

		names.add("Sushil");
		names.add("Henry");
		names.add("Ronnie");
		names.add("Siva");
		names.add("Reenu");
		names.add("Mira");
		names.add("Satya");
		names.add("Ravi");
		names.add("Mytri");
		names.add("Siva");// trying to add duplicate string,should not take
							// duplicates
		names.add("ravi");// adding lower case letters, Should display last in
							// the list
		names.add(null); // null will give NullpointerEX

		for (String name : names) {

			System.out.println("Student name :  " + name);
		}

	}

}
